package com.jwthhealth_pub.find.adapter;



import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jwthhealth_pub.R;

import java.util.ArrayList;
import java.util.List;

public class FindCardGrideViewAdapter extends BaseAdapter {
	public Context context;
	LayoutInflater layoutInflater;
	private List<String> names = new ArrayList<String>();

	public FindCardGrideViewAdapter(Context context,List<String> names) {
		this.context = context;
		this.layoutInflater = LayoutInflater.from(context);
        this.names = names;
	}

	@Override
	public int getCount() {

		return names.size();

	}

	@Override
	public Object getItem(int position) {

		return names.get(position);
	}

	@Override
	public long getItemId(int position) {

		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		VH vh = null;
		if (convertView == null) {
			vh = new VH();
			convertView = layoutInflater.inflate(R.layout.find_card_grideview_item, null);
			vh.textName = (TextView) convertView.findViewById(R.id.tv_name);
			if(position%2==0){
				vh.textName.setBackground(context.getResources().getDrawable(R.drawable.bg_yuan_main_shape));
				vh.textName.setTextColor(Color.WHITE);
			}
			convertView.setTag(vh);
		} else {
			vh = (VH) convertView.getTag();
		}
		vh.textName.setText(names.get(position));
		
		return convertView;
	}

	class VH {
		TextView textName;
	}
}
